/**
 * CEP Mobile Manager on Android July 2012 
 */
package com.orange.cepmanager.android;

import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;

/**
 *Helper class providing methods and constants common to other classes in the
 * app.
 * @author Fairouz OUBENALI
 * 
 */
public final class CEPManagerCommon {

	// this class can not be initialized
	private CEPManagerCommon() {

	}

	/*
	 * ==========================================================================
	 * = * GCM constants * *
	 * ======================================================================
	 */

	/**
	 * Google API project id registered to use GCM.
	 */
	public final static String SENDER_ID = "372163857055";
	// notification
	public static Notification gcmNotification = new Notification();

	/**
	 *  The rules commands
	 */
	public static enum CommandCEP {
		deleteRule ,addRule, updateRule, stopCEPEngine , startCEPEngine, event, message
	}
	

	/**
	 * Intent used to display a message in the screen.
	 */
	public static final String DISPLAY_MESSAGE_ACTION = "com.orange.cepmanager.android.activity.DISPLAY_MESSAGE";

	/**
	 * Intent's extra that contains the message to be displayed.
	 */
	public static final String EXTRA_MESSAGE = "message";

	/**
	 * Notifies UI to display a message.
	 * <p>
	 * This method is defined in the common helper because it's used both by the
	 * UI and the background service.
	 * 
	 * @param context
	 *            application's context.
	 * @param message
	 *            message to be displayed.
	 */
	public static void displayMessage(Context context, String message) {
		Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
		intent.putExtra(EXTRA_MESSAGE, message);
		context.sendBroadcast(intent);
	}
	/**
	 * id GCM registered 
	 */
	
	public static String regId="";

	/*
	 * ==========================================================================
	 * = * URL of the CEP Engine * *
	 * ======================================================================
	 */

	/**
	 * Method CRUD
	 */
	public static enum Method {
		POST, GET, PUT, DELETE
	}

	/**
	 * Base URL of the CEP Engine
	 */
	public static final String SERVER_URL = "http://cepengine.appspot.com";
	
	/** thread to enregister on server app engine
	 * 
	 */
	public static AsyncTask<Void, Void, Void> mRegisterTask;
	
	/*
	 * Phone PATH
	 */
	public final static String PATH_REGISTER_PHONE = "/ceprest/phone/register";
	public final static String PATH_UNREGISTER_PHONE = "/ceprest/phone/unregister";
	public final static String PATH_GET_ALL_PHONES = "/ceprest/phone/view";
	public final static String PATH_UPDATE_PHONE = "/ceprest/phone/update";
	public final static String PATH_SEARCH_PHONE = "/ceprest/phone/searchPhones";

	/*
	 * ==========================================================================
	 * = * TAG name of classes used on log messages * *
	 * ======================================================================
	 */

	public final static String CEPMANAGER_TAG = "CEPManagerApplication";
	public final static String CEP_MOBILE_TAG = "CEPMobile";
	public final static String SERVICE_TAG = "Service";
	public final static String LOCATION_LISTENER_TAG = "LocationListener";

	/**
	 * package activity
	 */
	public final static String CEP_MOBILE_MANAGER_TAG = "CEPMobileManager";
	public final static String GCM_DEMO_TAG = "GCMDemo";

	/**
	 * package GCM
	 */
	public final static String GCM_SERVER_TAG = "GCMServer";
	public final static String GCM_INTENT_SERVICE_TAG = "GCMIntentService";
	public final static String GCM_MESSAGE_COMMAND_TAG = "GCMMessageCommand";
	public final static String GCM_CLIENT_TAG = "GCMClient";

	/**
	 * package REST
	 */
	public final static String CEPMANAGER_REST_TAG = "GCMServer";
	
	/**
	 * package esper
	 */
	public final static String CEP_MANAGER_TAG = "CEPManager";

	/*
	 * ==========================================================================
	 * = * constants Events * *
	 * ======================================================================
	 */

	public final static String EVENT_TYPE_BROADCAST = "broadcast";
	public final static String EVENT_TYPE_PHONE_STATE_CHANGED = "phone state changed";
	public final static String EVENT_TYPE_OUTGOING_PHONE_CALL = "outgoing phone call";
	public final static String EVENT_TYPE_SMS_RECEIVED = "sms received";
	public static boolean sendEvent = true;
	public final static String ACTION_SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
	
	

	/*
	 * ==========================================================================
	 * = * Event Geolocation * *
	 * =====================================================================
	 */

	public final static String EVENT_TYPE_LOCATION = "location";
	public final static String EVENT_TYPE_LOCATION_STATUS = "location status";
	public final static String EVENT_TYPE_LOCATION_PROVIDER_DISABLED = "location provider disabled";
	public final static String EVENT_TYPE_LOCATION_PROVIDER_ENABLED = "provider enabled";
	public final static String EVENT_TYPE_CONNECTIVITY_CHANGED = "connectivity changed";

	// geolocation distance and times
	public final static long LOCATION_MIN_UPDATE_TIME = 1000l * 1;
	public final static float LOCATION_MIN_UPDATE_DISTANCE = 100f;
	public final static boolean DEBUG_ONLY_LOG_EVENT = true;
	
	/*
	 * ==========================================================================
	 * = * Proxy Orange* *
	 * ======================================================================
	 */

	/**
	 * Proxy Host
	 */
	public final static String PROXY_HOST = "p-goodway.rd.francetelecom.fr";

	/**
	 * Proxy Port
	 */
	public final static String PROXY_PORT = "3128";

	/**
	 * 
	 */
	public static void setProxyProperties() {
		System.setProperty("http.proxyHost", PROXY_HOST);
		System.setProperty("http.proxyPort", PROXY_PORT);
	}

}
